Undersampled magnetic resonance (MR) image reconstruction performance is related to two fundamental problems: where to sample and how to reconstruct the image. Previously developed deep learning-based magnetic resonance imaging (MRI) methods, including undersampled mask optimization and reconstruction, require large-scale, high-quality, and patient-based datasets for training, which presents a challenge in practical clinical scenarios. To reduce the dependence on datasets and perform undersampling and reconstruction simultaneously, we propose a novel joint learned optimized undersampling and constrained reconstruction method for accelerated MRI by a reference-driven deep image prior (J-LOUCR). Inspired by the deep image prior (DIP), J-LOUCR involves no pretraining procedure, resulting in no dependence on large-scale training datasets. The implementation of J-LOUCR includes learned optimization of the undersampled mask and constrained reconstruction with the reference-driven DIP. In the first step, based on the traditional DIP, we introduce a reference image as the network input and propose a joint optimization problem of the undersampled mask and network parameters. Then, the joint optimization problem is deconstructed into subproblems and solved by using the alternative iteration strategy to obtain the optimal undersampled mask guided by the reference image. In the second step, for the optimal undersampled mask, we consider and recommend that the structural similarity between the reference and target MR images be used as prior information. Under the dual drivers of the reference image as the network input and prior constraint, J-LOUCR optimizes the network parameters and then completes reconstruction. Experiments on invivo MR scans demonstrate that J-LOUCR can achieve more accurate reconstruction with more details and features.